import { createRouter, createWebHistory } from 'vue-router'
import Login from '@/views/Login.vue'
import admin from '@/views/admin.vue'
import goodsCategory from '@/views/Goods/goodsCategory.vue'
import goodsMassage from '@/views/Goods/goodsMassage.vue'
import expiring from '@/views/Inventory/expiring.vue'
import Alerts from '@/views/Inventory/Alerts.vue'
import home from '@/views/home.vue'
import employeeManagement from '@/views/employeeManagement.vue'
import UserAvatar from '@/views/user/UserAvatar.vue'
import UserInfo from '@/views/user/UserInfo.vue'
import UserResetPassword from '@/views/user/UserResetPassword.vue'
import orders from '@/views/orders.vue'
import vendor from '@/views/vendor.vue'
import stats from '@/views/stats.vue'
import inventory from '@/views/Inventory/inventory.vue'
import stockIn from '@/views/Inventory/stockIn.vue'
import stockOut from '@/views/Inventory/stockOut.vue'

const routes = [{
  path: '/login',
  component: Login,
},
{
  path: '/',
  component: Login,
},
{
  path: '/404',
  component: () => import('@/views/404.vue'),
},
{
  path: '/:catchAll(.*)', 
  redirect: '/404',
},
{
  path: '/admin',
  component: admin,
  redirect: '/admin/home',
  children:[
    {path: '/admin/home',meta: {name: '系统首页'},component: home},
    {path: '/admin/goodsCategory',meta: {name: '商品分类'},component: goodsCategory},
    {path: '/admin/goodsMassage',meta: {name: '商品信息'},component: goodsMassage},
    {path: '/admin/expiring',meta: {name: '临期商品'},component: expiring},
    {path: '/admin/Alerts',meta: {name: '库存预警'},component: Alerts},
    {path: '/admin/employeeManagement',meta: {name: '员工管理'},component: employeeManagement},
    {path: '/admin/user/avatar',meta: {name: '更换头像'},component: UserAvatar},
    {path: '/admin/user/info',meta: {name: '基本资料'},component: UserInfo},
    {path: '/admin/user/resetPassword',meta: {name: '重置密码'},component: UserResetPassword},
    {path: '/admin/orders',meta: {name: '订单管理'},component: orders},
    {path: '/admin/vendor',meta: {name: '供应商管理'},component: vendor},
    {path: '/admin/stats',meta: {name: '数据分析'},component: stats},
    {path: '/admin/inventory',meta: {name: '库存详情'},component: inventory},
    {path: '/admin/stockIn',meta: {name: '入库管理'},component: stockIn},
    {path: '/admin/stockOut',meta: {name: '出库管理'},component: stockOut}
  ],
}
]

//  开启路由
const router = createRouter({
  history: createWebHistory(),
  routes: routes
})

export default router
